/**
 * Created by Administrator on 14-3-18.
 */
function uploadSuccess(file, serverData) {
	try {
		var json = $.parseJSON(serverData);
		var itemHTML = '<a data-sea="ColorBox" href="'+json.url+'" class="thumbnail"><img src="'+json.url+'" /></a>' +
				'<input type="hidden" name="logo" value="'+json.url+'" /><a href="javascript:voil(0);" class="delImg btn btn-danger btn-xs"><i class="glyphicon glyphicon-trash"></i></a>';
		$('#SWFUpload_0').hide();
		$('#thumbLogo').append(itemHTML);
		$('#thumbLogo').seaLoad();
		$('#thumbLogo').on('click', '#thumbLogo a.delImg', function(){
			if(confirm('真的要删除最近上传的【'+file.name+'】文件吗？')){
				$(this).closest('#thumblogo').remove();
				$('#SWFUpload_0').show();
			}
			return false;
		});
		updateDisplay.call(this, file);
	} catch (ex) {
		this.debug(ex);
	}
}

function uploadBannerSuccess(file, serverData) {
	try {
		var json = $.parseJSON(serverData);
		var itemHTML = '<a data-sea="ColorBox" href="'+json.url+'" class="thumbnail"><img src="'+json.url+'" /></a>' +
		               '<input type="hidden" name="banner" value="'+json.url+'" /><a href="javascript:voil(0);" class="delImg btn btn-danger btn-xs"><i class="glyphicon glyphicon-trash"></i></a>';
		$('#SWFUpload_1').hide();
		$('#thumbBanner').append(itemHTML);
		$('#thumbBanner').seaLoad();
		$('#thumbBanner').on('click', '#thumbBanner a.delImg', function(){
			if(confirm('真的要删除最近上传的【'+file.name+'】文件吗？')){
				$(this).closest('#thumbBanner').remove();
				$('#SWFUpload_1').show();
			}
			return false;
		});
		updateDisplay.call(this, file);
	} catch (ex) {
		this.debug(ex);
	}
}

function updateDisplay(file) {
	$('#tdCurrentSpeed').text(SWFUpload.speed.formatBPS(file.currentSpeed));
	$('#tdAverageSpeed').text(SWFUpload.speed.formatBPS(file.averageSpeed));
	$('#tdMovingAverageSpeed').text(SWFUpload.speed.formatBPS(file.movingAverageSpeed));
	$('#tdTimeRemaining').text(SWFUpload.speed.formatTime(file.timeRemaining));
	$('#tdTimeElapsed').text(SWFUpload.speed.formatTime(file.timeElapsed));
	$('#tdPercentUploaded').text(SWFUpload.speed.formatPercent(file.percentUploaded));
	$('#tdSizeUploaded').text(SWFUpload.speed.formatBytes(file.sizeUploaded));
	$('#tdProgressEventCount').text(this.customSettings.progressCount);
}

var SWFupload_logo = {
		post_params: {haseName: '__hash__',hashValue : $('meta[name=__hash__]').attr('content'),target:'/data/upload/Good/logo/'},
		button_text: '<span>上传Logo</span>',
		queueDom: 'div id="thumbLogo"',
		file_size_limit : "100 MB",
		file_types : "*.*",
		file_types_description : "All Files",
		file_upload_limit : 100,
		file_queue_limit : 0,
		upload_success_handler : uploadSuccess
	},
	SWFupload_banner = {
		post_params: {haseName: '__hash__',hashValue : $('meta[name=__hash__]').attr('content'),target:'/data/upload/Good/banner/'},
		button_text: '<span class="theFont">上传Banner</span>',
		queueDom: 'div id="thumbBanner"',
		file_size_limit : "100 MB",
		file_types : "*.*",
		file_types_description : "All Files",
		file_upload_limit : 100,
		file_queue_limit : 0,
		upload_success_handler : uploadBannerSuccess
	};
